package com.situ.project1.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.project1.mapper.EmployeeMapper;
import com.situ.project1.pojo.Employee;
import com.situ.project1.service.EmployeeService;
import com.situ.project1.util.PaginateInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author:yzy
 * @date:2024/8/10
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {
    private EmployeeMapper employeeMapper;
    @Autowired
    public EmployeeServiceImpl(EmployeeMapper employeeMapper) {
        this.employeeMapper = employeeMapper;
    }
    @Override
    public List<Employee> findAll(PaginateInfo pi, Employee employee) {
        try (Page<Employee> __ = PageHelper.startPage(pi.getPageNo(), pi.getPageSize())){
            return employeeMapper.findAll(employee);
        }
    }

    @Override
    public boolean add(Employee employee) {
        return employeeMapper.add(employee);
    }

    @Override
    public boolean update(Employee employee) {
        return employeeMapper.update(employee);
    }

    @Override
    public boolean delete(Integer[] ids) {
        return employeeMapper.delete(ids);
    }

    @Override
    public List<Employee> findRest(LocalDateTime startTime,LocalDateTime endTime) {
        return employeeMapper.findRest(startTime,endTime);
    }

    @Override
    public Employee findEmpId(String empName) {
        return  employeeMapper.findEmpId(empName);
    }
}
